/* clock em Hz */
#define F_CPU 16000000UL

#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>

#include "t_setups.h"
#include "serial_teste.h"
#include "servo_utils.h"
#include "tacho.h"

void main_init(void) {

  timer2_init();
  serial_init((F_CPU/SERIAL_BAUD/16)-1);
  tacho_init();

}

int main(void) {

  char msg[40];
  uint32_t rpm_int=0;

  main_init();
  /* Enable Interrupts */
  sei();
  
  while (1){
    if (TASK2_FLAG) {
      rpm_int = tacho_get_rpm();
      sprintf(msg,"RPM:%u\n",rpm_int);
      serial_transmit(msg);
      TASK2_FLAG = 0;
    }
    
  }
  return 0;
};

